//
// Created by shiminli on 2023/12/28.
//

#ifndef DDOFFICE_ROUTER_H
#define DDOFFICE_ROUTER_H


#include "hv/HttpService.h"
#include "hv/httpdef.h"
#include "../utils/number.h"
#include "ctime"
#include "hv/hlog.h"
#include "../sql/SQLHelper.h"
#include "../sql/tabs/registers.h"
#include "../sql/tabs/accounts.h"
#include "../sql/tabs/verify_codes.h"
#include "../utils/dd_encryption.h"
#include "../utils/dd_token.h"
#include "../sql/DDRedis.h"


using namespace std;
using namespace ddoffice;

struct CommonParameter{
    string platform;
    int arecode = -1;
};

struct CommonParameterName{
    string platform = "platform";
    string arecode = "arecode";
    string mobile = "mobile";
};

class Router {
public:
    static CommonParameterName parameterName;

    static void Register(hv::HttpService& router);
    static CommonParameter parsParameter(const hv::Json &body);
private:

    static void printRequest(const string& methodName,const string& body){
        cout << "\nrequest-------------------------------------> "<<methodName <<" body: "<<body <<endl;
    }
    static void printResponse(const string& methodName,const string& body){
        cout << "\nresponse-------------------------------------> "<<methodName <<" body: "<<body <<endl;
    }
    static int response_msg(const HttpContextPtr& ctx,hv::Json& result, int code = 200, const char* message = NULL){
        result["code"] = code;
        result["message"] = message;
        string str = result.dump();
        printResponse(ctx->url(), str);
        return ctx->send(str, ctx->request->content_type);
    }

};


#endif //DDOFFICE_ROUTER_H
